<?php

namespace app\index\controller;

use app\index\controller\Base;




class User extends Base
{


    // 显示列表页
    public function index($id)
    {
        $M = model('User');
        $this->assign('channel',$M->getchannels());
        $this->assign('user',$M->getuserinfo($id));
        return $this->fetch();
    }

    // 显示列表页
    public function setpic($id)
    {
        $M = model('User');
        $this->assign('channel',$M->getchannels());
        $this->assign('user',$M->getuserinfo($id));
        return $this->fetch();
    }


    









    
    // 显示列表页
    public function userinfo()
    {

        $u = model('User');
        $user = $u->getUser(1);
        $channel = db('Channel')->field(['Name','id'])->order('id', 'asc')->select();
        return view('userinfo',[
            'title' => '主页',
            'channel' => $channel,
            'user' => $user,
        ]);
    }




    // 显示列表页
    public function list()
    {
        $list = db('Channel')->field(['Name','id'])->order('id', 'asc')->select();
        return view('list',[
            'title' => '主页',
            'list' => $list
        ]);
    }

    // 根据id 显示帖子详情
     public function postinfo($id)
    {
        $channel = db('Channel')->field(['Name','id'])->order('id', 'asc')->select();
        $post = db('post')->find($id);
        $user = db('user')->find($post['uid']);
        return view('postinfo',[
            'title' => '主页',
            'post' => $post,
            'channel' => $channel,
            'user' => $user
        ]);
    }

    // 根据id 显示发表帖子页面 
     public function dzhpost()
    {
        $channel = db('Channel')->field(['Name','id'])->order('id', 'asc')->select();
        return view('dzhpost',[
            'title' => '主页',
            'channel' => $channel,
        ]);
    }


     public function tjpost()
    {
        var_dump($_POST);die();
    }


}
